package com.btex.app.pager;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.btex.app.Config;
import com.btex.app.treaty.TreatyFragment;

public class FragmentAdapter extends FragmentPagerAdapter {
    private FragmentHangQing fragment1;
    private FragmentNews fragment2;
    private FragmentTrade fragment3;
    private FragmentAdmins fragment4;
    private FragmentLogin fragment5;
    private TreatyFragment mTreatyFragment;


    public FragmentAdapter(FragmentManager fm) {
        super(fm);
        fragment1 = new FragmentHangQing();
    }

    @Override
    public Fragment getItem(int id) {


        switch (id) {
            case Config.TAB_FRAGMENT1:


                if (fragment2 == null)

//					fragment1 = new FragmentHangQing();
                fragment2 = new FragmentNews();
                return fragment2;

            case Config.TAB_FRAGMENT2:

                if (fragment1 == null)

//					fragment2 = new FragmentNews();
                fragment1 = new FragmentHangQing();
                return fragment1;

            case Config.TAB_FRAGMENT3:

                if (fragment3 == null)

                fragment3 = new FragmentTrade();
                return fragment3;
            case Config.TAB_FRAGMENT4:


                if (fragment4 == null)

                fragment4 = new FragmentAdmins();
                return fragment4;

            case Config.TAB_FRAGMENT5:


                if (fragment5 == null)

                fragment5 = new FragmentLogin();
                return fragment5;


//            case Config.TAB_COUNT_heyue:
//                if (mTreatyFragment == null) {
//                    mTreatyFragment = new TreatyFragment();
//                    return mTreatyFragment;
//                }


        }
        return null;
    }


    @Override
    public int getCount() {
        return Config.TAB_COUNT;
    }


}
